package com.wcs.exam.controller.admin.resp;

import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.Valid;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;

import java.io.Serial;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

/**
 * <p>
 * Admin-试卷信息-详情查看响应对象
 * </p>
 *
 * @author wcs
 * @since 2025-03-11
 */
@Getter
@Setter
@Accessors(chain = true)
@Schema(description = "Admin-试卷信息-详情查看响应对象")
public class AdminPaperDetailViewResp implements Serializable {

    @Serial
    private static final long serialVersionUID = 1L;

    @Schema(description = "主键")
    private Long id;

    @Schema(description = "试卷类型(1:普通试卷、2:题库试卷)")
    private Integer paperType;

    @Schema(description = "试卷名称")
    private String paperName;

    @Schema(description = "分类ID")
    private Long categoryId;

    @Schema(description = "答卷时间(分钟)")
    private Integer answerTime;

    @Schema(description = "总分")
    private BigDecimal totalScore;

    @Schema(description = "及格分数")
    private BigDecimal passScore;

    @Schema(description = "及格百分比")
    private Integer passPercentage;

    @Schema(description = "试题数量")
    private Integer questionCount;

    @Schema(description = "随机组题设置(0:关闭、1:开启)")
    private Boolean randomCombine;

    @Schema(description = "乱序设置(0:关闭、1:开启)")
    private Boolean derangement;

    @Schema(description = "题目乱序(0:关闭、1:开启)")
    private Boolean questionDerangement;

    @Schema(description = "选项乱序(0:关闭、1:开启)")
    private Boolean optionDerangement;

    @Schema(description = "发布状态(0:未发布，1:已发布)")
    private Integer publishStatus;

    @Schema(description = "状态")
    private Integer status;

    @Schema(description = "排序")
    private Integer sort;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Schema(description = "创建时间")
    private LocalDateTime gmtCreate;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Schema(description = "修改时间")
    private LocalDateTime gmtModified;

    /*--------------------------------------------------- 拓展信息 ---------------------------------------------------*/

    @Schema(description = "分类名称")
    private String categoryName;

    @Schema(description = "试卷大题")
    private List<PaperTitle> paperTitles;

    @Data
    @Schema(name = "AdminPaperDetailViewResp.PaperTitle", description = "Admin-试卷信息-查看-试卷大题-响应对象")
    public static class PaperTitle implements Serializable {

        @Serial
        private static final long serialVersionUID = -9113596713823807307L;

        @Schema(description = "主键ID")
        private Long id;

        @Schema(description = "标题名称")
        private String titleName;

        @Schema(description = "单选题数量")
        private Integer singleChoiceCount;

        @Schema(description = "多选题数量")
        private Integer multipleChoiceCount;

        @Schema(description = "判断题数量")
        private Integer judgmentCount;

        @Schema(description = "填空题数量")
        private Integer gapFillingCount;

        @Schema(description = "简答题数量")
        private Integer shortAnswerCount;

        @Schema(description = "排序")
        private Integer sort;

        @Schema(description = "试卷试题")
        private List<PaperQuestion> paperQuestions;
    }

    @Data
    @Schema(name = "AdminPaperDetailViewResp.PaperQuestion", description = "Admin-试卷信息-查看-试卷试题-响应对象")
    public static class PaperQuestion implements Serializable {

        @Serial
        private static final long serialVersionUID = -8144760270312468147L;

        @Schema(description = "试题父ID")
        private Long questionParentId;

        @Schema(description = "题目ID")
        private Long questionId;

        @Schema(description = "题目类型(1:单选题、2:多选题、3:判断题、4:填空题、5:简答题)")
        private Integer questionType;

        @Schema(description = "题目分值")
        private BigDecimal questionScore;

        @Schema(description = "多选题得分方式(1:设置漏选得分、2:每个正确选项得分)")
        private Integer multiScoreWay;

        @Schema(description = "多选题得分")
        private BigDecimal multiScore;

        @Schema(description = "填空题得分方式(1:每题得分、2:每空得分)")
        private Integer fillScoreWay;

        @Schema(description = "填空题得分(设置填空题得分方式为2时使用)")
        private BigDecimal fillScore;

        @Schema(description = "排序")
        private Integer sort;

        @Schema(description = "难度等级(1:简单、2:一般、3:困难)")
        private Integer difficultyLevel;

        @Schema(description = "题目内容")
        private String questionTitle;

        @Schema(description = "题目答案")
        private String questionAnswer;

        @Schema(description = "题目解析")
        private String questionAnalysis;

        @Schema(description = "填空数")
        private Integer optionCount;

        @Schema(description = "题目答案ID")
        private List<Long> questionAnswerIds;

        @Valid
        @Schema(description = "选项信息")
        private List<QuestionOption> options;
    }

    @Data
    @Schema(name = "AdminPaperDetailViewResp.QuestionOption", description = "Admin-试卷信息-查看-选项-响应对象")
    public static class QuestionOption implements Serializable {

        @Serial
        private static final long serialVersionUID = 3698580623245157959L;

        @Schema(description = "主键")
        private Long id;

        @Schema(description = "选项内容")
        private String optionContent;

        @Schema(description = "排序")
        private Integer sort;
    }
}
